View Javadoc
1 /* 2 * Copyright (c) 2001 by 3 * Siegfried GOESCHL <mailto:siegfried.goeschl@itserv.at>; 4 * and Dima STADNIK <mailto:5d5@mail.ru>; 5 * 6 * This program is free software. 7 * 8 * You may redistribute it and/or modify it under the terms of the GNU 9 * General Public License as published by the Free Software Foundation. 10 * Version 2 of the license should be included with this distribution in 11 * the file LICENSE, as well as License.html. If the license is not 12 * included with this distribution, you may find a copy at the FSF web 13 * site at 'www.gnu.org' or 'www.fsf.org', or you may write to the 14 * Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139 USA. 15 * 16 * THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND, 17 * NOT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR 18 * OF THIS SOFTWARE, ASSUMES _NO_ RESPONSIBILITY FOR ANY 19 * CONSEQUENCE RESULTING FROM THE USE, MODIFICATION, OR 20 * REDISTRIBUTION OF THIS SOFTWARE. 21 */ 22 23 package test.junit.extensions; 24 25 import java.util.Random; 26 import junit.framework.*; 27 import junit.extensions.*; 28 29 /*** 30 * Tests ConfigurableTestCase class. 31 * 32 * @author Siegfried GOESCHL 33 * @author Dima STADNIK 34 */ 35 public class ConfigurableTestCaseTest extends ConfigurableTestCase { 36 37 public ConfigurableTestCaseTest( String name ) { 38 super(name); 39 } 40 41 public static void main(String args[]) { 42 junit.textui.TestRunner.run( ConfigurableTestCaseTest.suite() ); 43 } 44 45 public static Test suite() { 46 TestSuite suite= new TestSuite(); 47 suite.addTest( new ConfigurableTestCaseTest( "testGetKeyWithBaseNameKey" ) ); 48 suite.addTest( new ConfigurableTestCaseTest( "testgetKeyWithBaseKey" ) ); 49 suite.addTest( new ConfigurableTestCaseTest( "testGetKeyWithKey" ) ); 50 suite.addTest( new ConfigurableTestCaseTest( "testGetKeyWithClassNameKey" ) ); 51 suite.addTest( new ConfigurableTestCaseTest( "testGetInteger" ) ); 52 suite.addTest( new ConfigurableTestCaseTest( "testGetUndefinedKey" ) ); 53 suite.addTest( new ConfigurableTestCaseTest( "testGetChar" ) ); 54 suite.addTest( new ConfigurableTestCaseTest( "testGetBoolean" ) ); 55 suite.addTest( new ConfigurableTestCaseTest( "testGetByte" ) ); 56 suite.addTest( new ConfigurableTestCaseTest( "testGetShort" ) ); 57 suite.addTest( new ConfigurableTestCaseTest( "testGetLong" ) ); 58 suite.addTest( new ConfigurableTestCaseTest( "testGetFloat" ) ); 59 suite.addTest( new ConfigurableTestCaseTest( "testGetDouble" ) ); 60 suite.addTest( new ConfigurableTestCaseTest( "testGetStrings" ) ); 61 62 63 return suite; 64 } 65 66 /*** 67 * Retrieve a value with full key name : base + name + key 68 */ 69 70 public void testGetKeyWithBaseNameKey() { 71 assertTrue( getString( "key1" ).equals( "key1" ) ); 72 } 73 74 /*** 75 * Retrieve a value with base + key 76 */ 77 78 public void testgetKeyWithBaseKey() { 79 assertTrue( getString( "key2" ).equals( "key2" ) ); 80 } 81 82 /*** 83 * Retrieve a value with full key name : class + name + key 84 */ 85 86 public void testGetKeyWithClassNameKey() { 87 assertTrue( getString( "key3" ).equals( "key3" ) ); 88 } 89 90 /*** 91 * Retrieve a value with a key only 92 */ 93 94 public void testGetKeyWithKey() { 95 assertTrue( getString( "key4" ).equals( "key4" ) ); 96 } 97 98 /*** 99 * Retrieve a value with full key name : class + name + key 100 */ 101 102 public void testGetInteger() { 103 assertTrue( getInteger( "key" ) == 9999 ); 104 } 105 106 /*** 107 * Retrieve a value with a key which is not defiend 108 */ 109 110 public void testGetUndefinedKey() { 111 try { 112 int result = getInteger( "key" ); 113 } 114 115 catch( IllegalArgumentException e ) { 116 return; 117 } 118 119 fail(); 120 } 121 122 /*** 123 * Test access of TestProperties 124 */ 125 126 public void testGetBoolean() { 127 assertTrue( getBoolean( "key" ) == true ); 128 } 129 130 131 /*** 132 * Test access of TestProperties 133 */ 134 135 public void testGetChar() { 136 assertTrue( getChar( "key" ) == 'c' ); 137 } 138 139 /*** 140 * Test access of TestProperties 141 */ 142 143 public void testGetStrings() { 144 assertTrue( getStrings( "key" )[0].equals("key0") ); 145 assertTrue( getStrings( "key" )[1].equals("key1") ); 146 assertTrue( getStrings( "key" )[2].equals("key2") ); 147 assertTrue( getStrings( "keyEx" )[0].equals("key1") ); 148 assertTrue( getStrings( "keyEx" )[1].equals("key2") ); 149 } 150 151 /*** 152 * Test access of TestProperties 153 */ 154 155 public void testGetByte() { 156 assertTrue( getByte( "key" ) == 13 ); 157 } 158 159 /*** 160 * Test access of TestProperties 161 */ 162 163 public void testGetShort() { 164 assertTrue( getShort( "key" ) == 1234 ); 165 } 166 167 /*** 168 * Test access of TestProperties 169 */ 170 171 public void testGetLong() { 172 assertTrue( getLong( "key" ) == 99999999 ); 173 } 174 175 /*** 176 * Test access of TestProperties 177 */ 178 179 public void testGetFloat() { 180 assertTrue( getFloat( "key" ) == (float) 3.12 ); 181 } 182 183 /*** 184 * Test access of TestProperties 185 */ 186 187 public void testGetDouble() { 188 assertTrue( getDouble( "key" ) == 3.1214927 ); 189 } 190 }

This page was automatically generated by Maven